<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="<?php echo base_url('public/admin/js/enable_disable.js'); ?>"></script>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>List of keywords</title>
    </head>
    <body>
        <div id="wraper">
            <?php $this->load->view('admin/menu', array('action' => $action)); ?>
            <div id="content">
                <div id="add">
                    <center>
                        <form action="" method="POST" id="add_keyword">
                            <label>Keyword: </label>
                            <input type="text" name="keyword"/>
                            <label>Category : </label>
                            <select name="id_categories">
                                <?php  foreach($categories as $item): ?>
                                    <option value="<?php echo $item['id'] ?>"><?php echo $item['name'] ?></option>
                                <?php  endforeach; ?>
                            </select>
                            <input type="submit" name="submit" value="Add">
                        </form>
                    </center>
                </div>
                <div id="thongbao"><!-- thông báo  enable/disabel ---></div>
                <div class="total_pagination">
                    <div id="show_search" class="float_left">
                        <b>Total :&nbsp;</b>
                        About  <span><?php echo '3242' ?></span> result.
                    </div>
                    <div id="pagination" class="float_right">
                        <?php echo "paginnation"; ?>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="show_data">
                    <table border="0" cellspacing="0" cellpadding="5" width="100%">
                        <tr>
                            <td colspan="4" align="right">
                                <form method="get" class="status_all" align='right'>
                                    <span style="color:brown;">Enable or Disable all keywords ? </span>
                                    <input type="radio" value="1" name="status_all" class="enable_all" name_site="keywords"> Enable
                                    <input type="radio" value="0" name="status_all" class="disable_all" name_site="keywords"> Disable
                                </form>
                            </td>
                        </tr>
                        <tr>
                            <td class="title"> Name</td>
                            <td class="title">
                                <form method="get" class="status_all">
                                    <select name="id_categories"  onchange="location.href = 'keywords.php?id_categories=' + this.value">
                                        <option value="0"> &laquo; &nbsp; Select category &raquo; </option>
                                        <?php  foreach($categories as $item): ?>
                                            <option value="<?php echo $item['id'] ?>" <?php if (isset($_GET['id_categories']) && $_GET['id_categories'] == $item['id']) echo 'selected=selected'; ?>><?php echo $item['name'] ?></option>
                                        <?php  endforeach; ?>
                                    </select>
                                </form>
                            </td>
                            <td class="title"> Operation</td>
                            <td class="title"> Status</td>  
                        </tr>
                        <?php foreach ($keywords as $item): ?>
                            <tr>
                                <td class="show_name"><?php echo $item["name"]; ?></td>
                                <td class="show_name"><?php echo $categories[$item["id_categories"] - 1]['name']; ?></td>
                                <td class="infor_show">
                                    <a href="edit_keywords.php?id=<?php echo $item["id"]; ?>" class="edit">Edit</a>
                                    <a href="delete_keywords.php?id=<?php echo $item["id"]; ?>" class="delete">Delete</a>
                                </td>
                                <td>
                                    <form method="get" id="<?php echo $item["id"]; ?>">
                                        <input type="radio" value="1" name="status" class="enable" <?php if ($item["status"] == 1) echo "checked='checked'" ?> onchange="if (this.checked)
                                            enable('?id=<?php echo $item['id']; ?>&name_site=keywords.php&status=' + this.value);"> Enable
                                        <input type="radio" value="0" name="status" class="disable" <?php if ($item["status"] == 0) echo "checked='checked'" ?> onchange="if (this.checked)
                                            disable('?id=<?php echo $item['id']; ?>&name_site=keywords.php&status=' + this.value);"> Disable
                                    </form>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </table>
                </div><!-- End: #keywork; -->
            </div> <!-- End #content -->
            <?php $this->load->view('admin/footer'); ?>
        </div><!-- End #wraper -->
    </body>
</html>
